package com.lrc.dentalbackend.controller;

import com.lrc.dentalbackend.common.ResponseResult;
import com.lrc.dentalbackend.domain.dto.MessageDTO;
import com.lrc.dentalbackend.domain.vo.FriendVO;
import com.lrc.dentalbackend.domain.vo.MessageVO;
import com.lrc.dentalbackend.service.MessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("/message")
public class MessageController {
    @Resource
    private MessageService messageService;

    @ApiOperation("保存文字信息")
    @PostMapping("/save")
    public ResponseResult saveMessage(@RequestBody MessageDTO message){
        messageService.saveMessage(message);
        return ResponseResult.ok();
    }

    @ApiOperation("查看当前与该好友所有聊天记录")
    @GetMapping("/get/{id}")
    public ResponseResult getMessage(@PathVariable Long id){
        List<MessageVO> messageVOList = messageService.getMessage(id);
        return ResponseResult.ok(messageVOList);
    }

    @ApiOperation("获取当前用户消息列表")
    @GetMapping("/get/messageList")
    public ResponseResult getMessageListByUserId(){
        Set<FriendVO> friends = messageService.getMessageListByUserId();
        return ResponseResult.ok(friends);
    }

    @ApiOperation("删除当前用户消息列表")
    @PostMapping("/del/messageList/{id}")
    public ResponseResult delMessageById(@PathVariable Long id){
        messageService.delMessageListById(id);
        return ResponseResult.ok();
    }




}
